IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[FdsAnimal_UpdateNumberOfAnimals]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[FdsAnimal_UpdateNumberOfAnimals]
GO
/****** Object:  StoredProcedure [dbo].[FdsAnimal_UpdateNumberOfAnimals]    Script Date: 05/06/2009 16:14:15 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/***************************************************************************
* Name:			FdsAnimal_UpdateNumberOfAnimals
* Purpose:		Update number of animals on the protocol level for approved amendments
*
***************************************************************************/
CREATE PROCEDURE dbo.FdsAnimal_UpdateNumberOfAnimals
(			
			@FolderNumber varchar(12),
			@NumberOfAnimals int
)
AS
BEGIN
	SET NOCOUNT ON

	UPDATE Protocol SET NumberOfAnimals = @NumberOfAnimals
		WHERE ProtocolNumber = @FolderNumber
		AND ModuleType = 'A'
		AND IsCurrent = 1
		AND ISNULL(NumberOfAnimals, 0) != ISNULL(@NumberOfAnimals, 0)

	SET NOCOUNT OFF

END

GO